Replace

Basic and Crystal syntax.

Overloads
Arguments
Returns

String value.

Action

Replace returns a String in which a specified substring has been replaced with another substring a specified number of times. As an option, you can also specify where in the String to begin replacing, and return a String starting from that position.

Typical use

To systematically replace in a String one substring with another.

Examples

The following examples are applicable to both Basic and Crystal syntax. They assume that inputString is the text String "Monday is my day off. Can we meet next Monday?".

Replace (inputString, "Monday", "Wednesday")

Returns "Wednesday is my day off. Can we meet next Wednesday?".

Replace (inputString, "Monday", "Wednesday", 23)

Returns "Can we meet next Wednesday?" The replacement begins at the 23rd character from the beginning of the original inputString. The returned string is this portion of the string with the substitutions made.

Replace (inputString, "Monday", "Wednesday", 1, 1)

Returns "Wednesday is my day off. Can we meet next Monday?" There is only 1 replacement beginning at the 1st character from the beginning of the original inputString. The returned string is thus the original string with the single substitution made.

Replace (inputString, "monday", "Wednesday", 1, -1, 0)

Returns the same inputString with no replacements since no match was found for "monday" with a case-sensitive comparison.

Replace (inputString, "monday", "Wednesday", 1, -1, 1)

Returns the inputString with both occurrences of "Monday" replaced by "Wednesday". That is, "Wednesday is my day off. Can we meet next Wednesday?".

Comments


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com